package io.kiki.task.server.job.task.support.executor.job;

import io.kiki.task.common.core.enums.JobTaskTypeEnum;
import io.kiki.task.server.job.task.support.JobExecutor;

import java.util.concurrent.ConcurrentHashMap;


public class JobExecutorFactory {

    private static final ConcurrentHashMap<JobTaskTypeEnum, JobExecutor> CACHE = new ConcurrentHashMap<>();

    public static void registerJobExecutor(JobTaskTypeEnum taskInstanceType, JobExecutor executor) {
        CACHE.put(taskInstanceType, executor);
    }

    public static JobExecutor getJobExecutor(Integer type) {
        return CACHE.get(JobTaskTypeEnum.valueOf(type.toString()));
    }
}
